[//
    async function( kuo,Context,context){
        
        let $features = await Kuoplus(kuo.class);
        let $_GET = kuo.get;
        let $tuid = $_GET['tuid'] ?$_GET['tuid']:0;//推广uid
        let $appid = $features['configure']['公众号'] && $features['configure']['公众号']['0']?$features['configure']['公众号']['0']:"";
        let $redirect_uri = KuoLink( ['login','weixin_openid_back']);
        let $chauid = 0;
        let ISAPP = kuo.Path['0']?kuo.Path['0']:"";
        let $Security = await Mem.Get("session/"+kuo.sessionid);
        if($Security && $Security["uid"]){
            $chauid = $Security["uid"];
        }
        if(!$Security ){
            $Security={
                uid:0,
                code:0,
                tuid:0
            };
        }
        $Security.sessionid = kuo.sessionid;
        if($tuid > 0){
            $Security.tuid = $tuid;
        }
        $Security.platform =  strpos(kuo.agent,"ISAPP")?"ISAPP":"";
        if(ISAPP!=""){
            $Security.platform = "ISAPP";
        }
        if($_GET['tiaozhuan'] && $_GET['tiaozhuan'] != ""){
            $Security.tiaozhuan = decodeURIComponent($_GET['tiaozhuan']);
        }
        let $state = Md5(kuo.sessionid);
        await Mem.Set('opentoken/'+$state ,$Security,360);
        let $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='+$appid+'&response_type=code&scope=snsapi_userinfo&state='+$state+'&redirect_uri='+encodeURIComponent($redirect_uri)+'#wechat_redirect';
        if (strpos( kuo.agent , "Messenger") !== false) {
            Context.statusCode = 302;
            Context.headers["Location"] = $url ;
            Context.body = "";
        }else{
            let KUO = {
                url:$url,
                chaurl:KuoLink( ['login','getuser']),
                sessionid:kuo.sessionid,
                state:$state,
            };
            Context.body = `<!DOCTYPE html>
            <html>
            <head>
              <meta charset="utf-8">
              <title>微信登陆</title>
              <meta name="renderer" content="webkit" />
              <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
              <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" />
              <style>
              *{margin:0;padding:0;}
              body{background:#000;}
              #zzz{padding:80px;margin:0 auto;width:350px;text-align:center;color:#fff;font-size:16px;}
              p img{width:100%;}
              p.wztishi{margin-bottom:20px;background:#333;padding:10px;}
              </style>
            </head>
            <body> 
                <div id="zzz">
                    <p class="wztishi">
                        请使用微信 “扫一扫” 登陆
                    </p>
                    <p id="qrcode"></p>
                </div>
            </body>
            </html>
            <script src="${CDNHOST}Tpl/jquery.js"></script>
            <script src="${CDNHOST}Tpl/qrcode.min.js"></script>
            <script type="text/javascript">
            window.UIMUI =[];
            var NUM = 0;
            $(function(){
                function getuser(){
                    NUM ++;
                    
                    if(NUM > 120){
            
                        window.location.href = window.location.href;
            
                    }else{
                        $.getJSON("${KUO.chaurl}/?state=${KUO.state}",function(data){
                          
                            if(data && data.code == 1){
                                
                                if(data.data.tiaozhuan){
                                    window.location.href = data.data.tiaozhuan;
                                }else{
                                    window.location.href = '${WZHOST}';
                                }
            
                            }else{
                                setTimeout(getuser, 3000);
                            }
                        });
                        
                    }  
                }
            
               var qrcode = new QRCode(document.getElementById("qrcode"), {
                    text: "${KUO.url}",
                    width: 350,
                    height: 350,
                    colorDark : "#000000",
                    colorLight : "#ffffff",
                    correctLevel : QRCode.CorrectLevel.L
                });
                   
                setTimeout(getuser, 3000);
            
            });
            </script>`;
        }
    } 
]